/*
* @Author: Marte
* @Date:   2017-08-02 22:05:33
* @Last Modified by:   Marte
* @Last Modified time: 2017-08-02 22:13:40
*/

function lun3d()
{

    init();
    function init()
    {
        // 设置flat属性
        $('.rightpic').attr('flat','right');
        $('.contpic').attr('flat','cont');
        $('.leftpic').attr('flat','left');
    }

    var left_move,  //记录左边的对象
    cont_move,  //记录中间的对象
    right_move,  //记录右边的对象
    flat;   //判断按了左或是右

    var to_left=function()
    {
        left_move.attr('flat','right');
        cont_move.attr('flat','left');
        right_move.attr('flat', 'cont');//右边边中间
    }
     var to_right=function(){

                                  left_move.attr('flat', 'cont');//左图层变成右

                                  cont_move.attr('flat', 'right');//中间边左边

                                  right_move.attr('flat', 'left');//右边边中间



                                 };


       function left_obj(){
        left_move=$('[flat=left]');//取得属性flat为左的
        if(flat=='left')
        {
            left_move.animate({
                right:"120px",
                width:"120px",
                height:"160px"
            },300);
            left_move.css("z-index","10");
        }else if(flat=='right')
        {
            left_move.animate({
                left:"180px",
                width:"140px",
                height:"190px"
            })
             left_move.css("z-index","11");
        }

       }

    function right_obj(){
        right_move=$('[flat=right]');//取得属性flat为左的
        if(flat=='left')
        {
            left_move.animate({
               left:"180px",
                width:"140px",
                height:"190px"
            },300);
            left_move.css("z-index","11");
        }else if(flat=='right')
        {
            left_move.animate({
                right:"120px",
                width:"120px",
                height:"160px"
            })
             left_move.css("z-index","10");
        }

       }
  function cont_obj(){
        cont_move=$('[flat=cont]');//取得属性flat为左的
        if(flat=='left')
        {
            left_move.animate({
               left:"120px",
                width:"120px",
                height:"160px"
            },300);
            left_move.css("z-index","10");
        }else if(flat=='right')
        {
            left_move.animate({
                right:"120px",
                width:"120px",
                height:"160px"
            })
             left_move.css("z-index","10");
        }

       }

       $('.centent1_left_lunbo').find('.buttonright').click(function()
       {
        alert('fsf');
        toleft();
       })

       $('.centent1_left_lunbo').find('.buttonleft').click(function()
       { alert('fsf');
        toright();
       })

       toright();
       function toleft()
       {
             flat="left";
            // 三个都运动
            left_obj();
            right_obj();
            cont_obj();
            // 重置flat
            to_left();
       }

       function toright()
       {
         flat="right";
        // 三个都运动
        left_obj();
        right_obj();
        cont_obj();
        // 重置flat
        to_right();
       }
}


$(function()
{
     lun3d();
$('#buttonright').click(function()
       {
        alert('fsf');

       })

})